import { Dimension } from '../common/dimension';
import { Vector } from '../common/vector';

export class MathUtils {
  static isIntersection(location1: Vector, dimension1: Dimension, location2: Vector, dimension2: Dimension): boolean {
    const topLeft1 = location1;
    const bottomRight1 = new Vector(location1.x + dimension1.width, location1.y + dimension1.height);
    const topLeft2 = location2;
    const bottomRight2 = new Vector(location2.x + dimension2.width, location2.y + dimension2.height);

    return (
      topLeft1.x < bottomRight2.x &&
      bottomRight1.x > topLeft2.x &&
      topLeft1.y < bottomRight2.y &&
      bottomRight1.y > topLeft2.y
    );
  }

  private constructor() {}
}
